package com.bwie.doctorclient.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.doctorclient.domain.vo.CommonlyDrugVO;
import com.bwie.doctorclient.domain.vo.DepartmentVO;
import com.bwie.doctorclient.domain.vo.DrugVO;
import com.bwie.doctorclient.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/drug")
public class DrugController {
    @Autowired
    private DrugService drugService;

    /**
     * 获取常用药品列表
     * @return
     */
    @GetMapping("/getCommonlyDrugList")
    public Result getCommonlyDrugList() {
        List<CommonlyDrugVO> drugList = drugService.getCommonlyDrugList();
        return Result.success(drugList);
    }

    /**
     * 删除常用药品
     * @param id
     * @return
     */
    @DeleteMapping("/deleteCommonlyDrug/{id}")
    public Result deleteCommonlyDrug(@PathVariable Long id){
        drugService.deleteCommonlyDrug(id);
        return Result.success();
    }

    /**
     * 新增常用药品
     * @param drugId
     * @return
     */
    @PostMapping("/addCommonlyDrug/{drugId}")
    public Result addCommonlyDrug(@PathVariable Long drugId){
        drugService.addCommonlyDrug(drugId);
        return Result.success();
    }

    /**
     * 获得所有科室及科室下的症状
     * @return
     */
    @GetMapping("/getDepartmentSymptomList")
    public Result getDepartmentSymptomList(){
        List<DepartmentVO> list = drugService.getDepartmentSymptomList();
        return Result.success(list);
    }

    /**
     * 根据科室症状id获取药品信息
     * @param ids
     * @return
     */
    @PostMapping("/getDrugByDepartmentSymptomId")
    public Result getDrugByDepartmentSymptomId(@RequestBody Long[] ids){
        List<CommonlyDrugVO>  list = drugService.getDrugByDepartmentSymptomId(ids);
        return Result.success(list);
    }

    /**
     * 获取药品详情
     * @param id
     * @return
     */
    @GetMapping("/getDrugDetail/{id}")
    public Result getDrugDetail(@PathVariable Long id){
        DrugVO drugVO = drugService.getDrugDetail(id);
        return Result.success(drugVO);
    }
}
